package xyz.example.securegeyser;

import org.bukkit.plugin.java.JavaPlugin;
import javax.crypto.SecretKey;
import org.bukkit.plugin.messaging.PluginMessageListener;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

// new imports for internal listener and command classes
import xyz.example.securegeyser.listener.IncomingSecureListener;
import xyz.example.securegeyser.command.SecureSendCommand;

public class SecureGeyserBridge extends JavaPlugin {

    public static final String CHANNEL = "secure:bridge";
    private SecretKey key;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        key = AESCipher.readKey(getConfig().getString("aes-key"));

        getServer().getMessenger().registerOutgoingPluginChannel(this, CHANNEL);
        getServer().getMessenger().registerIncomingPluginChannel(this, CHANNEL,
                new IncomingSecureListener(this));

        getCommand("securesend").setExecutor(new SecureSendCommand(this));

        getLogger().info("SecureGeyserBridge enabled. Using channel '" + CHANNEL + "'.");
    }

    public SecretKey getKey() {
        return key;
    }
}
